package servlets;
import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import utility.UserSession;

public class AddCreditCard extends HttpServlet{
public AddCreditCard(){
	super();
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{
	
        response.setContentType("text/html");
        String cardno= request.getParameter("cardno");
        String expiration=request.getParameter("expidt");
        String name=request.getParameter("name");
        String cvv=request.getParameter("cvv");
        UserSession sess = new UserSession();
        String message=sess.addCard(cardno,name,cvv,expiration);
        
        if(message.equals("Success"))
        {
       	 request.setAttribute("message", "You have successfully purchased the quiz");
       	RequestDispatcher RequestDispatcherObj =request.getRequestDispatcher("/view/UserHome.jsp");
        RequestDispatcherObj.forward(request, response);
        }
        else
        {
       	 request.setAttribute("message", message);
        }
}
}